//# sourceURL=http://uMapApp/Earth/DataSourceView/WMTSImageryDataSourceView
define([
    "mhjs/mhjs",
    "uMap/uMap",
    "uEarth/uEarth",
    "./ImageryDataSourceView"
], function (
    mhjs,
    uMap,
    uEarth,
    ImageryDataSourceView
) {

    function WMTSImageryDataSourceView(option) {

        var _this = this;
        ImageryDataSourceView.call(_this, option);

        _this.LayerOption = {
            url            : option.url,
            layer          : option.mapLayer,
            style          : option.style || "",
            format         : option.format || 'image/png',
            tileMatrixSetID: option.tileMatrixSetID,
            maximumLevel   : option.maxLevel
        };

        if (option.tileMatrixSetWithLabel) {
            _this.LayerOption.tileMatrixLabels = _class.getTileMatrixLabels(option.tileMatrixSetID, option.maxLevel || 21);
        }

        if (option.tilingScheme) {
            _this.LayerOption.tilingScheme = new uEarth.GeographicTilingScheme();
        }

        if (option.rectangle) {
            _this.rectangleCoordinates = uEarth.Rectangle.fromDegrees(
                option.rectangle[0],
                option.rectangle[1],
                option.rectangle[2],
                option.rectangle[3]
            );

            _this.LayerOption.rectangle = _this.rectangleCoordinates;
        }

        _this.imagery = new uMap.ImageryLayer({
            objectOption: {
                imageryProvider    : new uEarth.WebMapTileServiceImageryProvider(_this.LayerOption),
                rectangle          : _this.rectangle,
                minimumTerrainLevel: _this.minLevel,
                maximumTerrainLevel: _this.maxLevel,
                contrast           : _this.contrast
            }
        });

    }

    var _class = WMTSImageryDataSourceView;

    mhjs.Inherit(_class, ImageryDataSourceView);

    _class.getTileMatrixLabels = function (label, maxlevel) {
        var arr = [];
        for (var i = 0; i < maxlevel; i++) {
            arr.push(label + ":" + i);
        }
        return arr;
    };

    Object.defineProperties(_class.prototype, {});

    return _class;

});